package com.tencent.wxcloudrun.listener;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.alibaba.fastjson2.JSONObject;
import com.google.common.eventbus.Subscribe;
import com.tencent.wxcloudrun.manager.ActiManager;
import com.tencent.wxcloudrun.vo.request.acti.ActiJoinBlackReqVo;
import com.tencent.wxcloudrun.vo.request.acti.ActiJoinReqVo;
import com.tencent.wxcloudrun.vo.request.acti.ActiJoinSelectedReqVo;

import lombok.extern.slf4j.Slf4j;

/**
 * @Author ZhaoZiYin
 * @Date 2025/4/29
 * @Description 参与活动事件处理
 */
@Slf4j
@Component
public class EventListener {

    @Resource
    private ActiManager actiManager;

    /**
     * 参与活动
     */
    @Subscribe
    public void listen4ActiJoin(ActiJoinReqVo reqVo) {
        log.info("事件监听-参与活动-入参={}", JSONObject.toJSONString(reqVo));
        actiManager.joinToDb(reqVo);
    }

    /**
     * 入围活动
     */
    @Subscribe
    public void listen4ActiSelectedJoin(ActiJoinSelectedReqVo reqVo) {
        log.info("事件监听-入围活动-入参={}", JSONObject.toJSONString(reqVo));
        actiManager.joinSelectedToDb(reqVo);
    }

    /**
     * 黑箱活动
     */
    @Subscribe
    public void listen4ActiBlackJoin(ActiJoinBlackReqVo reqVo) {
        log.info("事件监听-黑箱活动-入参={}", JSONObject.toJSONString(reqVo));
        actiManager.joinBlackToDb(reqVo);
    }

}
